feat: creating memo references from markdown links #5474
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Edit: Marked as ready for review to hear from @johnnyjoygh what he thinks about this idea. The whole idea is still in just a draft stage.
Motivation
I use memos every day, primarily to write down notes using Zettelkasten method. The idea behind Zettelkasten is, that you write small notes and link them hypertextually together. To maintain clarity in Zettelkasten, it's recommended to maintain Structure notes - e.g. Structure note could be table of contents linking to other memos.
Memos already has the "Link memo" functionality, but in my case, it misses crucial feature, which is position and order of the links within the content. So instead, I currently rather link "basic" memos with "structured" memos manually, as I need to keep links organized in the "structured memo".
It would be nice to utilize memo's "Relation" functionality directly from the content, by e.g. linking to other memos, e.g.:
Implementation
This is just a prototype to showcase the functionality and potential implementation. In a nutshell, I'm adding goldmark's AST transformer, which runs over the parsed AST and adds
AttrMemosRefIDattribute to aLinknode, in case it includesmemos/<id>within the destination.This is lately gathered in
markdown@ExtractAllfunction and appended todata.MemoRefNames. After that, thisPayloadcontent is used inmemo_service@CreateMemofunction, to automatically generateMemoRelations and append them torelationsvariable, which is later used for creation of realtions.Screencast_20260111_144612.webm
Future work and improvements
Acknowledgements
I'm not experienced in Go. It was learning by doing experience with some amount of help from AI. Initially I wanted to implement this from the frontend only, but that stopped making sense after understanding the overall handling better.
Thank you for the time and dedication you're putting into Memos.